@extends('layouts.app')
@include('coupon.sidebar')
@section('content')
    <div class="content">
        <div class="row custom-invoice">
            @can('coupon-edit')
                <a class="btn btn-success" href="{{ route("admin.coupon.create") }}">添加优惠券</a>
            @endcan
            <br />
            <br />
            <table class="table table-striped table-hover">
                <thead>
                <tr>
                    <th>商铺</th>
                    <th>优惠券名称</th>
                    <th>有效期</th>
                    <th>价格限制</th>
                    <th>金额</th>
                    <th>适用范围</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                @foreach($data as $item)
                    <tr>
                        <td>{{ is_null($shop->get($item->shop_id))? "全部店铺" : $shop->get($item->shop_id)->name }}</td>
                        <td>{{ $item->title }}</td>
                        <td>{{ $item->shelf_life }}</td>
                        <td>{{ $item->price_limit/100 }}</td>
                        <td>{{ $item->money/100  }}</td>
                        <td>{{ $item->applicable }}</td>
                        <td>
                            @can('coupon-edit')
                                <a class="btn btn-primary btn-xs" href="{{ route('admin.coupon.edit', ['id' => $item->id]) }}"><i class="fa fa-edit"></i> 编辑</a>
                                <a class="btn btn-danger btn-xs delete-confirm" data-href="{{ route('admin.coupon.delete', ['id' => $item->id]) }}"><i class="fa fa-trash-o"></i> 删除</a>
                            @endcan
{{--                            @if (!$item->is_gift)--}}
{{--                                <a class="btn btn-success btn-xs" data-method="post" href="{{ route('admin.coupon.gift', ['id' => $item->id]) }}"><i class="fa fa-gift"></i> 设置为可赠送</a>--}}
{{--                            @endif--}}
                        </td>
                    </tr>
                @endforeach
                </tbody>
            </table>
            {{ $data->links() }}
        </div>
    </div>
@endsection
